package dbsync4j.core.loader.crawler;

import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import dbsync4j.core.behavior.DatabaseObject;
import dbsync4j.core.loader.behavior.DatabaseLoader;
import dbsync4j.core.types.ForeignKeyRule;

public class CrawlerForeignKeyRuleLoader implements DatabaseLoader<ForeignKeyRule> {

	@Override
	public ForeignKeyRule loadDatabaseObject(Object schemaObject) {
		
		schemacrawler.schema.ForeignKeyUpdateRule crawlerFkRule = (schemacrawler.schema.ForeignKeyUpdateRule) schemaObject;
		
		ForeignKeyRule fkType = null;

		switch (crawlerFkRule.getId()) {
			case 0: fkType = ForeignKeyRule.cascade;	break;
			case 3: fkType = ForeignKeyRule.noAction; break;
			case 1: fkType = ForeignKeyRule.restrict; break;
			case 4: fkType = ForeignKeyRule.setDefault; break;
			case 2: fkType = ForeignKeyRule.setNull; break;
			case -1:fkType = ForeignKeyRule.unknow; break;
		}
		
		return fkType;
	}

	@Override
	public void setDependantObjectOwner(DatabaseObject databaseObject) {
		throw new NotImplementedException();
	}

}
